home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 14 / hacker14.iso / programacao / visual / perl.exe / {app} / Templates / other / Foxpro.fpc < prev    next >
Encoding:
Text File  |  2003-01-11  |  1.8 KB  |  77 lines

  1. ****
  2. *
  3. * Main program. Checks to see if the local library database exists and creates
  4. * it if necessary. Then, the menu is run to start the application.
  5. *
  6. ****
  7.  
  8. #INCLUDE LIBRARY.H
  9.  
  10. PUBLIC aEnvironment[10] && Array to hold environment info to set and restore
  11. PUBLIC gnReturn         && Global return variable
  12.  
  13.  
  14. gnReturn = 0
  15. DO InitEnvironment WITH .T.
  16. SET PROC TO LIBSETUP
  17. IF !FILE (SETUP_FILE)
  18.       DO Install
  19. ENDIF
  20. IF gnReturn = 0
  21.       * Create a dummy file on the system so that next time we don't initialize.
  22.       hFile = FCREATE (SETUP_FILE)
  23.       =FCLOSE (hFile)
  24.       DO library.mpr
  25.       READ EVENTS
  26. ENDIF
  27. DO InitEnvironment with .F.
  28.  
  29. PROCEDURE InitEnvironment
  30. PARAMETERS llInit
  31.  
  32. IF llInit
  33.       PUSH MENU _MSYSMENU
  34.       SET CLASSLIB TO CONFLICT
  35.       IF SET ('talk')='ON'
  36.             SET TALK OFF
  37.             aEnvironment[1]='ON'
  38.       else
  39.             aEnvironment[1]='OFF'
  40.       endif
  41.       aEnvironment[2]=set('safety')
  42.       SET SAFETY OFF
  43.       aEnvironment[3] = set('exclusive')
  44.       SET EXCLUSIVE OFF
  45. ELSE
  46.       SET exclusive &aEnvironment[3]
  47.       SET safety &aEnvironment[2]
  48.       SET talk &aEnvironment[1]
  49.       CLOSE DATABASES ALL
  50.       RELEASE ALL
  51.       CLEAR ALL
  52.       POP MENU _MSYSMENU
  53. ENDIF
  54. ENDPROC
  55.  
  56. FUNCTION CheckExec
  57. PARAMETERS phConnect, pcExecString, pcCursor
  58.  
  59. LOCAL laErrors[10]
  60. LOCAL lcErrorString, lnRetVal
  61.  
  62. IF TYPE ('pcCursor') = 'L'
  63.       lnRetVal = SQLEXEC (phConnect, pcExecString)
  64. ELSE
  65.       lnRetVal = SQLEXEC (phConnect, pcExecString, pcCursor)
  66. ENDIF
  67.  
  68. IF lnRetVal < 0
  69.       =AERROR (laErrors)
  70.       lcErrorString = laErrors[1,2] + CHR(13) + CHR(10) + pcExecString
  71.       =MESSAGEBOX (lcErrorString, MB_OK + MB_ICONSTOP, FATAL_ERROR_LOC)
  72.       gnReturn = -1
  73.       =SQLDISCONNECT (phConnect)
  74.       RETURN TO MASTER
  75. ENDIF
  76. ENDFUNC
  77.